<html>
<head>
	<title>机构管理列表</title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<script src="../../static/bootstrap/js/jquery-3.4.1.min.js" type="text/javascript"></script>
	<script src="../../static/bootstrap/js/static-resources.js"></script>
</head>
<script type="text/javascript">
    $(function () {
        $(".footerPage").load("../footer.html");
        let DEFAULT_DATA_MODEL = {
            "bpaSerialNo":"",
            "bpaId":"",
            "bpaDate":"",
            "bpaName":"",
            "subsCode":"",
            "bpaState":"",
            "bpaInterveneState":"",
            "stageName":"",
            "startTime":"",
            "endTime":"",
            "bpaDateStart":"",
            "bpaDateEnd":"",
            "startTimeStart":"",
            "startTimeEnd":"",
            "endTimeStart":"",
            "endTimeEnd":"",
        };
        new Vue({
            el : '#app',
            mixins: [window.$DEFAULT_MIXIN],
            data: {
                queryParam: {
                    bpaSerialNo: "",
                    bpaId: "",
                    bpaName: "",
                    bpaState: "",
                    bpaDateStart: "",
                    bpaDateEnd: "",
                    startTimeStart: "",
                    startTimeEnd: "",
                    endTimeStart: "",
                    endTimeEnd: "",
                },
                pageInfo: {
                    page: 1,
                    size: 10,
                    total: 0
                },
                list:[],
                selected: null,

                show: false,
                readonly: false,
                loading: false,
                modelTitle:"",
                dataObj: {},
                opType: "",
            },
            watch:{
                opType(val, old){
                    if (val == "add") {
                        this.modelTitle = "机构管理新增";
                        this.show = true;
                        this.readonly = false;
                        this.dataObj = $.extend({}, DEFAULT_DATA_MODEL);
                    } else if (val == "update") {
                        this.modelTitle = "机构管理修改";
                        this.show = true;
                        this.readonly = false;
                        this.dataObj = $.extend({}, this.selected);
                    } else if (val == "view") {
                        this.modelTitle = "机构管理详情";
                        this.show = true;
                        this.readonly = true;
                        this.dataObj = $.extend({}, this.selected);
                    }
                }
            },
            computed:{
                paths(){
                    return [
                        {text: '首页', href: '/index.html'},
                        {text: '系统设置', href: '#'},
                        {text: '组织机构', href: '#'},
                        {text: '机构管理', href: 'admin/SOrgList.html'},
                    ]
                },
                fields(){
                    return [
                        {key: 'bpaSerialNo', label:'业务流水号', sortable: false},
                        {key: 'bpaId', label:'流程标识', sortable: false},
                        {key: 'bpaDate', label:'流程日期', sortable: false},
                        {key: 'bpaName', label:'流程名称', sortable: false},
                        {key: 'subsCode', label:'所属系统', sortable: false},
                        {key: 'bpaState', label:'流程状态', sortable: false,
                            formatter: function (value, key, item) {
                                return formatter_BAT_BATCH_STATE(value)
                            }},
						{key: 'bpaInterveneState', label:'人工干预', sortable: false,
                            formatter: function (value, key, item) {
                                return formatter_BAT_BATCH_INTERVENE_STATE(value)
                            }},
                        {key: 'stageName', label:'流程阶段', sortable: false},
                        {key: 'startTime', label:'地址', sortable: false},
                        {key: 'endTime', label:'启动时间', sortable: false},
                        {key: 'state', label:'结束时间', sortable: false},
                    ]
                },
                BAT_BATCH_STATE(){
                    return BAT_BATCH_STATE;
                },
                BAT_BATCH_INTERVENE_STATE(){
                    return BAT_BATCH_INTERVENE_STATE;
                }
            },
            methods:{
                onRowSelected(items){
                    this.selected = items[0];
                },
                submitQry(page){
                    if (page == true) {
                        this.pageInfo.page = 1;
                    }
                    let self = this;
                    JLEUtil.requestForm("api/bpm/bat/inst/batchs", "POST", null, $.extend({}, self.queryParam, self.pageInfo),
                        function(data, textStatus, jqXHR){
                            self.list = data.rows;
                            self.pageInfo.total = data.total;
                        },
                        function(jqXHR, textStatus, errorThrown){

                        });
                },
                resetContent(){
                    console.log("aaaaaaaaaaaaaaaa:"+this.queryParam.bpaState)
                    this.queryParam.bpaSerialNo = "";
                    this.queryParam.bpaId = "";
                    this.queryParam.bpaName = "";
                    this.queryParam.bpaState = "";
                    this.queryParam.bpaDateStart = "";
                    this.queryParam.bpaDateEnd = "";
                    this.queryParam.startTimeStart = "";
                    this.queryParam.startTimeEnd = "";
                    this.queryParam.endTimeStart = "";
                    this.queryParam.endTimeEnd = "";
                },
                toAddPage(){
                    this.opType = "add";
                },
                toModifyRecord(){
                    if (!this.selected) {
                        this.$bvToast.toast(`请选择一行数据`, {
                            title: '提示 ',
                            toaster: 'b-toaster-top-center',
                            solid: true
                        });
                        return;
                    }
                    this.opType = "update";
                },
                delRecord(){
                    if (!this.selected) {
                        this.$bvToast.toast(`请选择一行数据`, {
                            title: '提示 ',
                            toaster: 'b-toaster-top-center',
                            solid: true
                        });
                        return;
                    }

                    let self = this;
                    this.$bvModal.msgBoxConfirm(`你确定删除这条数据吗?`, {
                        title: '删除提示',
                        size: 'sm',
                        buttonSize: 'sm',
                        okVariant: 'success',
                        headerClass: 'p-2 border-bottom-0',
                        footerClass: 'p-2 border-top-0',
                        cancelTitle: "取消",
                        okTitle: "确定",
                        centered: true
                    }).then(value => {
                        if (!value) return;
                    JLEUtil.request("api/bpm/bat/inst/batch", "DELETE", null, { organno : this.selected.organno},
                        function(data, textStatus, jqXHR){
                            self.$bvToast.toast(`删除成功！`, {
                                title: '提示 ',
                                toaster: 'b-toaster-top-center',
                                solid: true
                            });
                            self.submitQry(true);
                        },
                        function(jqXHR, textStatus, errorThrown){

                        });
                })
                },
                toViewPage(){
                    if (!this.selected) {
                        this.$bvToast.toast(`请选择一行数据`, {
                            title: '提示 ',
                            toaster: 'b-toaster-top-center',
                            solid: true
                        });
                        return;
                    }
                    this.opType = "view";
                },
                saveInfo(){

                    let requestOptions = {
                        url : "api/bpm/bat/inst/batch",
                        type : "POST",
                        dataObj: this.dataObj,
                        success: (data)=>{
                        this.$bvToast.toast(data.message, {
                        title: '提示 ',
                        toaster: 'b-toaster-top-center',
                        solid: true
                    });
                    this.loading = false;
                    this.closeModel();
                    this.submitQry();
                },
                    error: (jqXHR, textStatus, errorThrown)=>{
                        this.loading = false;
                        this.$bvToast.toast("提交失败", {
                            title: '提示 ',
                            toaster: 'b-toaster-top-center',
                            solid: true
                        });
                    }
                };
                    if (this.opType == "add") {
                        requestOptions.type = "POST";
                    } else if (this.opType == "update") {
                        requestOptions.type = "PUT";
                    }

                    this.loading = true;
                    let self = this;
                    this.$refs.form.validate().then(success => {
                        if (!success) {
                        this.loading = false;
                        return;
                    }
                    JLEUtil.request(requestOptions.url, requestOptions.type, null,
                        requestOptions.dataObj,
                        requestOptions.success,
                        requestOptions.error
                    );
                });
                },
                doMonitorBatch(){
                    if (!this.selected) {
                        this.$bvToast.toast(`请选择一行数据`, {
                            title: '提示 ',
                            toaster: 'b-toaster-top-center',
                            solid: true
                        });
                        return;
                    }
                    var url = 'BatchMonitor.html?bpaSerialNo='+this.selected.bpaSerialNo+'&bpaId='+this.selected.bpaId;
                    JLEUtil.linkNewPage(url);
				},
                doUpdateBatBatchToContinue(){
                    if (!this.selected) {
                        this.$bvToast.toast(`请选择一行数据`, {
                            title: '提示 ',
                            toaster: 'b-toaster-top-center',
                            solid: true
                        });
                        return;
                    }
                    let self = this;
                    this.$bvModal.msgBoxConfirm(`是否确认要续跑流程?`, {
                        title: '提示',
                        size: 'sm',
                        buttonSize: 'sm',
                        okVariant: 'success',
                        headerClass: 'p-2 border-bottom-0',
                        footerClass: 'p-2 border-top-0',
                        cancelTitle: "取消",
                        okTitle: "确定",
                        centered: true
                    }).then(value => {
                        if (!value) return;
                    var params = {
                        bpaSerialNo : self.selected.bpaSerialNo,
                        bpaId : self.selected.bpaId,
                        batchAction : 'continue'
                    }
                    JLEUtil.request("api/bat/bpm/batch/info/action/", "GET", params,null,
                        function(data, textStatus, jqXHR){
                            self.$bvToast.toast(data.message, {
                                title: '提示 ',
                                toaster: 'b-toaster-top-center',
                                solid: true
                            });
                            self.submitQry(true);
                        },
                        function(jqXHR, textStatus, errorThrown){

                        });
                })
				},
                closeModel(){
                    this.show = false;
                    this.modelData = {};
                    this.opType = "";
                }
            },
            mounted(){
                this.submitQry(true);
            }
        })
    });

</script>
</head>
<body>
<div class="headerPage"></div>
<div id="app">
	<div class="container-fluid mt-3"  >
		<div class="row">
			<div class="col-sm-12 search-box" style="height: 230px;margin-right: 20px">
				<form role="form" style="text-align: right"   id="formData" class="row">
					<div class="form-group col-sm-3" >
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4"  label="业务流水号：" >
							<b-form-input size="sm" v-model="queryParam.bpaSerialNo"></b-form-input>
						</b-form-group>
					</div>
					<div class="form-group col-sm-3">
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4" label="流程标识：" >
							<b-form-input size="sm" v-model="queryParam.bpaId"></b-form-input>
						</b-form-group>
					</div>
					<div class="form-group col-sm-3">
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4" label="流程名称：" >
							<b-form-input size="sm" v-model="queryParam.bpaName"></b-form-input>
						</b-form-group>
					</div>
					<div class="form-group col-sm-3">
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4" label="流程状态：" >
							<b-form-select type="text" v-model="queryParam.bpaState" name="bpaState"  :disabled="readonly"
										   :options="BAT_BATCH_STATE"
										   value-field="enname" text-field="cnname"></b-form-select>
						</b-form-group>
					</div>
					<div class="form-group col-sm-3">
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4" label="流程日期(起)：" >
							<b-laydate v-model="queryParam.bpaDateStart" name="bpaDateStart" :disabled="readonly"></b-laydate>						</b-form-group>
					</div>
					<div class="form-group col-sm-3">
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4" label="流程日期(止)：" >
							<b-laydate v-model="queryParam.bpaDateEnd" name="bpaDateEnd"  :disabled="readonly"></b-laydate>						</b-form-group>
					</div>
					<div class="form-group col-sm-3">
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4" label="启动时间(起)：" >
							<b-laydate v-model="queryParam.startTimeStart" name="startTimeStart"  :disabled="readonly"></b-laydate>						</b-form-group>
					</div>
					<div class="form-group col-sm-3">
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4" label="启动时间(止)：" >
							<b-laydate v-model="queryParam.startTimeEnd" name="startTimeEnd" p :disabled="readonly"></b-laydate>						</b-form-group>
					</div>
					<div class="form-group col-sm-3">
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4" label="结束时间(起)：" >
							<b-laydate v-model="queryParam.endTimeStart" name="endTimeStart" :disabled="readonly"></b-laydate>						</b-form-group>
					</div>
					<div class="form-group col-sm-3">
						<b-form-group style="text-align: right" label-cols="4" label-cols-lg="4" label="结束时间(止)：" >
							<b-laydate v-model="queryParam.endTimeEnd" name="endTimeEnd"  :disabled="readonly"></b-laydate>						</b-form-group>
					</div>
					<div class="control-group col-sm-2">
						<div class="text-center">
							<b-button size="sm"  variant="primary" @click="submitQry(true)">&nbsp;&nbsp;查&nbsp;&nbsp;询&nbsp;&nbsp;</b-button>
							<b-button size="sm" variant="secondary" @click="resetContent">&nbsp;&nbsp;重&nbsp;&nbsp;置&nbsp;&nbsp;</b-button>
						</div>
					</div>
				</form>
				<!-- table -->
			</div>
			<div class="form-group col-sm-12 ">
				<div class="text-left">
					<b-button size="sm" variant="primary" @click="doUpdateBatBatchToContinue">&nbsp;&nbsp;&nbsp;续&nbsp;&nbsp;&nbsp;跑&nbsp;&nbsp;&nbsp;</b-button>
					<b-button size="sm" variant="primary" @click="doMonitorBatch">流程监控</b-button>
				</div>
			</div>
			<div class="row"></div>
		</div>
	</div>
	<div class="container-fluid">
		<!-- table start -->
		<b-table responsive hover selectable bordered fixed striped small
				 show-empty empty-text="查询列表为空"
				 @row-selected="onRowSelected"
				 selected-variant="primary"
				 select-mode="single" :fields="fields" :items="list" >
			<template v-slot:table-colgroup="scope">
				<col
						v-for="field in scope.fields"
						:key="field.key"
						:style="{ width: '180px' }"
				>
			</template>
			<template v-slot:cell()="data" >
				<div class="text-truncate">{{ data.value }}</div>
			</template>
		</b-table>
		<div class="float-right">
			<b-pagination
					v-model="pageInfo.page"
					:total-rows="pageInfo.total"
					:per-page="pageInfo.size"
					@change="submitQry"
			></b-pagination>
		</div>
		<!-- table end -->
	</div>

	<!--<b-modal  v-model="show" :title="modelTitle" size="xl"-->
			  <!--scrollable-->
			  <!--no-close-on-backdrop-->
			  <!--hide-header-close-->
			  <!--no-close-on-esc>-->
		<!--<b-container fluid>-->
			<!--<validation-observer ref="form">-->
				<!--<form role="form" >-->
					<!--<div class="row">-->
						<!--<div class="col-sm-6">-->
							<!--<validation-provider name="organno" :rules="{ required: true }" v-slot="validationContext">-->
								<!--<b-form-group label="业务流水号" label-cols-sm="4" label-align-sm="right">-->
									<!--<b-form-input type="text" v-model="dataObj.organno" :readonly="opType != 'add' || readonly"-->
												  <!--:state="getValidationState(validationContext)"-->
												  <!--name="organno" placeholder="业务流水号"></b-form-input>-->
									<!--<b-form-invalid-feedback >业务流水号不能为空</b-form-invalid-feedback>-->
								<!--</b-form-group>-->
							<!--</validation-provider>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<validation-provider name="bpaId" :rules="{ required: true }" v-slot="validationContext">-->
								<!--<b-form-group label="流程标识" label-cols-sm="4" label-align-sm="right">-->
									<!--<b-form-input type="text" v-model="dataObj.bpaId"-->
												  <!--:state="getValidationState(validationContext)"-->
												  <!--name="bpaId" placeholder="流程标识"  :readonly="readonly"></b-form-input>-->
									<!--<b-form-invalid-feedback >流程标识不能为空</b-form-invalid-feedback>-->
								<!--</b-form-group>-->
							<!--</validation-provider>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="机构简称" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.bpaDate" name="bpaDate"  placeholder="机构简称"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="所属法人业务流水号" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.bpaName" name="bpaName"  placeholder="所属法人业务流水号"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="机构级别" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-select type="text" v-model="dataObj.subsCode" name="subsCode"  placeholder="机构级别"  :disabled="readonly"-->
											   <!--:options="STD_ORG_LEVEL"-->
											   <!--value-field="enname" text-field="cnname"></b-form-select>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="上级业务流水号" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.bpaState" name="bpaState"  placeholder="上级业务流水号"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="机构负责人" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.bpaInterveneState" name="bpaInterveneState"  placeholder="机构负责人"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="联系电话" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.stageName" name="stageName"  placeholder="联系电话"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="地址" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.startTime" name="startTime"  placeholder="地址"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="邮编" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.endTime" name="endTime"  placeholder="邮编"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="地区编号" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.distno" name="distno"  placeholder="地区编号"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="地区名称" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.distname" name="distname"  placeholder="地区名称"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="是否营销中心" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-select type="text" v-model="dataObj.isMarketing" name="isMarketing"  placeholder="是否营销中心"  :disabled="readonly"-->
											   <!--:options="STD_PUB_YN"-->
											   <!--value-field="enname" text-field="cnname"></b-form-select>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="开办日期" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.launchdate" name="launchdate"  placeholder="开办日期"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="金融代码" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.fincode" name="fincode"  placeholder="金融代码"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
						<!--<div class="col-sm-6">-->
							<!--<b-form-group label="业务机构编号" label-cols-sm="4" label-align-sm="right">-->
								<!--<b-form-input type="text" v-model="dataObj.busiorganno" name="busiorganno"  placeholder="业务机构编号"  :readonly="readonly"></b-form-input>-->
							<!--</b-form-group>-->
						<!--</div>-->
					<!--</div>-->
				<!--</form>-->
			<!--</validation-observer>-->
		<!--</b-container>-->
		<!--<template v-slot:modal-footer>-->
			<!--<div class="control-group col-sm-12">-->
				<!--<div class="text-center">-->
					<!--<b-button variant="primary" @click="saveInfo" :disabled="loading">-->
						<!--<div v-if="loading">-->
							<!--<b-spinner small></b-spinner>-->
							<!--保存中...-->
						<!--</div>-->
						<!--<span v-else="loading">保存</span>-->
					<!--</b-button>-->
					<!--<b-button variant="secondary" @click="closeModel" :disabled="loading">返回</b-button>-->
				<!--</div>-->
			<!--</div>-->
		<!--</template>-->
	<!--</b-modal>-->
</div>
<div class="footerPage"></div>
</body>
</html>
